package JZOffer;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;

public class _22 {
    class Solution {
        public boolean VerifySquenceOfBST(int[] sequence) {
            int size = sequence.length;
            int i = 0;
            if (size == 0) return false;
            while (--size > 0) {
                System.out.println("hello");
                while (sequence[i++] < sequence[size]);
                while (sequence[i++] > sequence[size]);
//                while (sequence[i] < sequence[size]) i++;
//                while (sequence[i] > sequence[size]) i++;
                if (i < size) return false;
                i = 0;
            }
            return true;
        }
    }

    Solution getSolution() {
        return new Solution();
    }

    public static void main(String args[]) {
        _22 c = new _22();
        _22.Solution s = c.getSolution();
//        int[] sequence = {6};
//        int[] sequence = {6,8,7,9};
        int[] sequence = {6,7,12,9};
        System.out.println(s.VerifySquenceOfBST(sequence));
    }
}
